﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crosland.Automotriz.Core;
namespace Crosland.Automotriz.Data.Dao.Linq
{
    public class clsTD_AuxiliarDAO
    {

        private AutomotrizEntities ContextoDeObjs = new AutomotrizEntities();
        public bool Insertar(TD_AUXILIAR Obj)
        {
            try
            {
                ContextoDeObjs.AddObject("TD_AUXILIAR", Obj);
                ContextoDeObjs.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public bool Modificar(TD_AUXILIAR obj)
        {
            try
            {
                ContextoDeObjs.AttachTo("TD_AUXILIAR", obj);
                ContextoDeObjs.ObjectStateManager.ChangeObjectState(obj, System.Data.EntityState.Modified);
                ContextoDeObjs.SaveChanges();
            }
            catch (Exception)
            {
                return false;

            }
            return true;
        }
        public bool Eliminar(TD_AUXILIAR obj)
        {
            try
            {
                ContextoDeObjs.AttachTo("TD_AUXILIAR", obj);
                ContextoDeObjs.DeleteObject(obj);
                ContextoDeObjs.SaveChanges();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public List<TD_AUXILIAR> listar()
        {

            List<TD_AUXILIAR> lista = new List<TD_AUXILIAR>();
            try
            {
                var q = from c in ContextoDeObjs.TD_AUXILIAR
                        select c;
                lista = q.ToList();

            }
            catch (Exception)
            {
            }
            return lista;
        }
    }
}
